﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsAppTcChess
{
    /// <summary>
    /// 游戏类
    /// </summary>
    class Game
    {
        private const int Cols = 11;
        private const int Rows = 11;


        /// <summary>
        /// 绘制当前游戏场景
        /// </summary>
        /// <param name="g">绘图句柄</param>
        /// <param name="size">游戏区域尺寸</param>
        public void Draw(Graphics g, Size size)
        {
            //画背景
            Rectangle rec = new Rectangle(new Point(0,0), size);
            g.DrawImage(Properties.Resources.bg, rec);

            //画棋格
            int unitColWidth = size.Width / (Cols + 1);
            int unitRowHeight = size.Height / (Rows + 1);
            //画横线
            for (int i = 0; i < Rows; i++)
            {
                PointF pointStart = new PointF(unitColWidth, (i + 1) * unitColWidth);
                PointF pointEnd = new PointF(unitColWidth * Cols , (i + 1) * unitColWidth);
                g.DrawLine(new Pen(Color.Black), pointStart, pointEnd);
            }
            //画竖线
            for (int i = 0; i < Rows; i++)
            {
                PointF pointStart = new PointF((i + 1) * unitColWidth, unitRowHeight);
 
                PointF pointEnd = new PointF((i + 1) * unitColWidth, unitRowHeight * Rows);
                g.DrawLine(new Pen(Color.Black), pointStart, pointEnd);
            }


        }
    }
}
